/**
 * 
 */
package com.manage.action;

import java.util.List;

import org.apache.log4j.Logger;


import com.action.AbstractAction;
import com.manage.cache.ChannelManager;
import com.manage.model.Channel;
import com.manage.model.SyncConfig;
import com.manage.service.SyncConfigService;
import com.manage.service.SyncConfigServiceImpl;

/**
 * @author jinmei.wang
 *
 */
public class SyncConfigAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	public SyncConfigAction()
	{
		service = new SyncConfigServiceImpl();
		logger = Logger.getLogger(this.getClass());
	}
	
	public String execute()
	{
		return SUCCESS;
	}

	private List<SyncConfig> list;
	private SyncConfig       syncconfig;
	private String        type;
	private Channel channel;
	private SyncConfigService service ;
	
	public String list()
	{
		logger.debug("list account");
		channel = ChannelManager.getInstance().getChannel(channel.getId());
		list = service.getSyncConfigs(channel.getId());
		return SUCCESS;
	}
	
	public String show()
	{
		if (syncconfig.getId() >= 0)
		{
			syncconfig = service.getSyncConfig(syncconfig.getId());
			type = "update";
		}
		else
		{
			syncconfig.setId(-1);
			type = "insert";
		}

		return SUCCESS;
	}
	
	public String save()
	{
		service.saveSyncConfig(operator, type, syncconfig);
		return SUCCESS;
	}

	public List<SyncConfig> getList() {
		return list;
	}

	public void setList(List<SyncConfig> list) {
		this.list = list;
	}

	public SyncConfig getSyncconfig() {
		return syncconfig;
	}

	public void setSyncconfig(SyncConfig syncconfig) {
		this.syncconfig = syncconfig;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Channel getChannel() {
		return channel;
	}

	public void setChannel(Channel channel) {
		this.channel = channel;
	}
	
	

	
}
